#!/bin/bash

from='160315'
url='http://direct.mapswithme.com/direct/'
cf='../checksums'

#FIXME: ensure these entries do not contain spaces! else they'll be treated as two! maybe quoting them might work, but the for below will break that!
list=(
00_roboto_regular.ttf
01_dejavusans.ttf
02_droidsans-fallback.ttf
03_jomolhari-id-a3d.ttf
04_padauk.ttf
05_khmeros.ttf
06_code2000.ttf
07_roboto_medium.ttf

World.mwm
WorldCoasts.mwm
external_resources.txt
countries.txt

Hungary_Kozep-Magyarorszag.mwm
Hungary_Northern Great Plain.mwm
Hungary_Transdanubia.mwm

Romania_Centre.mwm
Romania_North_East.mwm
Romania_North_West.mwm
Romania_South.mwm
Romania_South_East.mwm
Romania_South_West.mwm
Romania_West.mwm

#FIXME: these are the old names (from 'latest' folder which is old! dec 2015)
USA_California.mwm
USA_California.mwm.routing
)


pushd 'MapsWithMe' || exit 1
echo "#Autogenerated checksums - will be overwritten on next update! Now is: `date`" > "$cf"

for i in "${list[@]}"; do
  echo "$i"
  wget -c "${url}${from}/${i}"
	ec="$?"
	if test "$ec" -ne 0; then
    echo "FAIL!"|grep --color=always 'FAIL'
  else
    sha1sum "$i" >> "$cf"
    sha256sum "$i" >> "$cf"
    sha512sum "$i" >> "$cf"
  fi
done

popd

